package com.contract.spirit.ui.exchange

import android.content.Context
import android.content.Intent
import com.contract.commonlib.util.ext.setOnSingleClickListener
import com.contract.commonlib.base.BaseActivity
import com.contract.commonlib.util.ToolUtils
import com.contract.commonlib.util.ext.showToast
import com.contract.spirit.R
import com.contract.spirit.config.Constant
import com.contract.spirit.databinding.ActivityExchangeRegisterUrlBinding
import com.contract.spirit.ui.exchange.bind.BindExchangeViewModel

/**
 * @author: witness
 * created: 2021/9/27
 * desc:
 */
class ExchangeRegisterUrlActivity :
    BaseActivity<ActivityExchangeRegisterUrlBinding, BindExchangeViewModel>() {
    override fun setContentView(): Int {
        return R.layout.activity_exchange_register_url
    }

    override fun initData() {
        val registerUrl = intent.getStringExtra(Constant.URL);
        if (!registerUrl.isNullOrBlank()) {
            val inviteCode = intent.getStringExtra(Constant.INVITECODE)
            mBinding.apply {
                tvRegisterUrl.text = registerUrl
                tvInviteCode.text = inviteCode
                tvCopyUrl.setOnSingleClickListener {
                    ToolUtils.copyToClip(mContext,registerUrl)
                    showToast("复制成功")
                }
                tvCopyInviteCode.setOnSingleClickListener {
                    ToolUtils.copyToClip(mContext,inviteCode)
                    showToast("复制成功")
                }
            }
        }
    }
    companion object{
        fun launch(context: Context, registerExchangeUrl:String?, inviteCode:String?){
            val intent = Intent(context, ExchangeRegisterUrlActivity::class.java)
            intent.putExtra(Constant.URL, registerExchangeUrl)
            intent.putExtra(Constant.INVITECODE, inviteCode)
            context.startActivity(intent)
        }
    }
}